<?php

namespace app\man\controller;

use think\Controller;
use think\Request;
use think\Db;
use think\Session;

class Site extends Controller
{
	public function  login()
	{
		return $this->fetch('login');
	}

	public function  checkLogin()
	{
		$username = trim(Request::instance()->post('username'));
        $password = md5(trim(Request::instance()->post('password')));
        $kouling = trim(Request::instance()->post('kouling'));
        $result = Db::name('member')->where(['username'=>$username,'password'=>$password,'kouling'=>$kouling])->find();
        if ($result) {
            Session::set('username',$result['username']);
            Session::set('kouling',md5(md5($result['kouling'])));
            $this->success('登陆成功', url('man/index/index'), 3);
        } else {
            $this->error('登陆失败');
        }
	}

	public function  loginOut()
	{
		Session::clear();
		$this->success('欢迎再来', url('man/site/login'), 3);
	}
}